home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / fish / 676-700 / 691 / cmanual / ace2.lha / Intuition / Graphics / Example4.c < prev    next >
C/C++ Source or Header  |  1992-05-01  |  5KB  |  139 lines

  1. /***********************************************************/
  2. /*                                                         */
  3. /* Amiga C Encyclopedia (ACE) V3.0      Amiga C Club (ACC) */
  4. /* -------------------------------      ------------------ */
  5. /*                                                         */
  6. /* Book:    ACM Intuition               Amiga C Club       */
  7. /* Chapter: Graphics                    Tulevagen 22       */
  8. /* File:    Example4.c                  181 41  LIDINGO    */
  9. /* Author:  Anders Bjerin               SWEDEN             */
  10. /* Date:    92-05-01                                       */
  11. /* Version: 1.10                                           */
  12. /*                                                         */
  13. /*   Copyright 1992, Anders Bjerin - Amiga C Club (ACC)    */
  14. /*                                                         */
  15. /* Registered members may use this program freely in their */
  16. /*     own commercial/noncommercial programs/articles.     */
  17. /*                                                         */
  18. /***********************************************************/
  19.  
  20. /* This program will open a normal window which is connected to the */
  21. /* Workbench Screen. We will then print a text string whith help of */
  22. /* Intuition's IntuiText structure. The text will be in underlined  */
  23. /* italic characters.                                               */
  24.  
  25.  
  26.  
  27. /* If your program is using Intuition you should include intuition.h: */
  28. #include <intuition/intuition.h>
  29.  
  30.  
  31.  
  32. struct IntuitionBase *IntuitionBase;
  33.  
  34.  
  35.  
  36. /* Declare a pointer to a Window structure: */ 
  37. struct Window *my_window;
  38.  
  39. /* Declare and initialize your NewWindow structure: */
  40. struct NewWindow my_new_window=
  41. {
  42.   40,            /* LeftEdge    x position of the window. */
  43.   20,            /* TopEdge     y positio of the window. */
  44.   400,           /* Width       400 pixels wide. */
  45.   150,           /* Height      150 lines high. */
  46.   0,             /* DetailPen   Text should be drawn with colour reg. 0 */
  47.   1,             /* BlockPen    Blocks should be drawn with colour reg. 1 */
  48.   NULL,          /* IDCMPFlags  No IDCMP flags. */
  49.   SMART_REFRESH| /* Flags       Intuition should refresh the window. */
  50.   WINDOWDRAG|    /*             Drag gadget. */
  51.   WINDOWDEPTH|   /*             Depth arrange Gadgets. */
  52.   ACTIVATE,      /*             The window should be Active when opened. */
  53.   NULL,          /* FirstGadget No Custom Gadgets. */
  54.   NULL,          /* CheckMark   Use Intuition's default CheckMark (v). */
  55.   "STYLE!",      /* Title       Title of the window. */
  56.   NULL,          /* Screen      Connected to the Workbench Screen. */
  57.   NULL,          /* BitMap      No Custom BitMap. */
  58.   0,             /* MinWidth    We do not need to care about these */
  59.   0,             /* MinHeight   since we have not supplied the window */
  60.   0,             /* MaxWidth    with a Sizing Gadget. */
  61.   0,             /* MaxHeight */
  62.   WBENCHSCREEN   /* Type        Connected to the Workbench Screen. */
  63. };
  64.  
  65.  
  66.  
  67. struct TextAttr my_font=
  68. {
  69.   "topaz.font",                 /* Topaz font. */
  70.   TOPAZ_EIGHTY,                 /* 80/40 characters (high-/low-res). */
  71.   FSF_ITALIC | FSF_UNDERLINED,  /* Underlined italic characters. */ 
  72.   FPF_ROMFONT                   /* Exist in ROM. */
  73. };
  74.  
  75. UBYTE my_text[]="Nice style! Italic and Underlined!";
  76.  
  77. struct IntuiText my_intui_text=
  78. {
  79.   1,         /* FrontPen, colour register 1. */
  80.   2,         /* BackPen, colour register 2. */
  81.   JAM2,      /* DrawMode, draw the characters with colour 1, on a colour */
  82.              /* 2 background. (White text on a black background) */ 
  83.   10, 20,    /* LeftEdge, TopEdge. */
  84.   &my_font,  /* ITextFont, use my_font. */
  85.   my_text,   /* IText, the text that will be printed. */
  86.              /* (Remember my_text = &my_text[0].) */
  87.   NULL       /* NextText, no other IntuiText structures are connected. */
  88. };
  89.  
  90.  
  91.  
  92. main()
  93. {
  94.   /* Open the Intuition Library: */
  95.   IntuitionBase = (struct IntuitionBase *)
  96.     OpenLibrary( "intuition.library", 0 );
  97.   
  98.   if( IntuitionBase == NULL )
  99.     exit(); /* Could NOT open the Intuition Library! */
  100.  
  101.  
  102.  
  103.   /* We will now try to open the window: */
  104.   my_window = (struct Window *) OpenWindow( &my_new_window );
  105.   
  106.   /* Have we opened the window succesfully? */
  107.   if(my_window == NULL)
  108.   {
  109.     /* Could NOT open the Window! */
  110.     
  111.     /* Close the Intuition Library since we have opened it: */
  112.     CloseLibrary( IntuitionBase );
  113.  
  114.     exit();  
  115.   }
  116.  
  117.  
  118.  
  119.   /* Tell Intuition to print the text: */
  120.   PrintIText( my_window->RPort, &my_intui_text, 0, 0 );
  121.  
  122.  
  123.  
  124.   /* We have opened the window, and everything seems to be OK. */
  125.   /* Wait for 30 seconds: */
  126.   Delay( 50 * 30);
  127.  
  128.  
  129.  
  130.   /* We should always close the windows we have opened before we leave: */
  131.   CloseWindow( my_window );
  132.  
  133.  
  134.   
  135.   /* Close the Intuition Library since we have opened it: */
  136.   CloseLibrary( IntuitionBase );
  137.   
  138.   /* THE END */
  139. }